import 'package:flutter/material.dart';
import 'package:local_coffee/components/rgba.dart';
import 'package:local_coffee/jsonserialize/shopping_cart/data.dart';
import 'package:local_coffee/utils/global.dart';

class GoodsMsgRow extends StatelessWidget {
  
  final bool marginBottom;

  final ShoppingCartData data;

  ///
  /// ```
  /// @param {bool} marginBottom 底边距
  /// @param {ShoppingCartData} data
  /// ```
  GoodsMsgRow({
    Key key,
    this.data,
    this.marginBottom = true
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      key: key,
      margin: EdgeInsets.only(bottom: 12),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Container(
                child: Text(
                  '$data.name',
                  style: TextStyle(
                    color: RGBA.rgba383838,
                    fontSize: 15,
                    fontWeight: FontWeight.bold
                  ),
                ),
              ),
              Container(
                child: Text(
                  '${G.handleGoodsDesc(data.specName).replaceAll(',', '/')}',
                  style: TextStyle(
                    color: RGBA.rgba383838,
                    fontSize: 10
                  ),
                ),
              )
            ],
          ),
          Row(
            children: <Widget>[
              Text(
                'x ${data.number}',
                style: TextStyle(
                  color: RGBA.rgba505050,
                  fontSize: 13
                ),
              ),
              Container(
                margin: EdgeInsets.only(left: 80),
                child: Text(
                  '￥ ${data.price * data.number}',
                  style: TextStyle(
                    color: RGBA.rgba383838,
                    fontSize: 14,
                    fontWeight: FontWeight.bold
                  ),
                ),
              )
            ],
          )
        ],
      ),
    );
  }
}